package game

import (
	"engine/log"
	"servers/app/client/conn"
	_ "servers/app/client/protos/game/g101"
	"servers/models/error_code"
	"servers/models/protos/google/pb/common_protos"
	"servers/models/protos/google/pb/net_protos"
)

func TokenLoginReq(c conn.Client, req *net_protos.GameTokenLoginReq) *net_protos.GameTokenLoginRsp {
	rsp := &net_protos.GameTokenLoginRsp{}
	err := c.Send(req, rsp)
	if err != nil || rsp.Code != 0 {
		log.GetLogger().ErrorPrintf("TokenLoginReq errcode:%v or  err:%v", rsp.Code, err)
		rsp.Code = error_code.ErrorCodeUnknown
	}
	return rsp
}

func SitDownReq(c conn.Client) *net_protos.GameSitDownRsp {
	rsp := &net_protos.GameSitDownRsp{
		ErrCode: &common_protos.GlobalResponseError{},
	}
	if err := c.Send(&net_protos.GameSitDownReq{}, rsp); err != nil {
		log.GetLogger().ErrorPrintf("SitDownReq err:%v", err)
		rsp.ErrCode.Code = error_code.ErrorCodeUnknown
	}
	return rsp
}

func StandUpReq(c conn.Client) *net_protos.GameStandUpRsp {
	rsp := &net_protos.GameStandUpRsp{}
	if err := c.Send(&net_protos.GameStandUpReq{}, rsp); err != nil {
		log.GetLogger().ErrorPrintf("StandUpReq err:%v", err)
		rsp.Code = error_code.ErrorCodeUnknown
	}
	return rsp
}
